#include "TcpSocket.hpp"

int main(int argc, char* argv[]){
  if(argc < 3){
    printf("Cli [ip] [port]\n");
    return 0;
  }
  TcpSocket Cli;
  if(!Cli.CreateSocket()){
    return 0;
  }
  std::string svr_ip = argv[1];
  uint16_t svr_port = atoi(argv[2]);
  if(!Cli.Connect(svr_ip, svr_port)){
    return 0;
  }
  while(1){
    std::string buf;
    std::cout << "说点啥:";
    getline(std::cin, buf);
    if(!std::cin){
      break;
    }
    Cli.Send(buf);
    buf.clear();
    Cli.Recv(buf);
    std::cout<<"服务端回复: "<<buf<<std::endl;
  }
  Cli.Close();
  return 0;
}
